/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-05-24
 * Time: 9:01
 */
public class IsUnivalTreeGuanFan {

        public boolean isUnivalTree(TreeNode root) {
            if (root == null) {
                return true;
            }
            if (root.left != null) {
                if (root.val != root.left.val || !isUnivalTree(root.left)) {
                    return false;
                }
            }
            if (root.right != null) {
                if (root.val != root.right.val || !isUnivalTree(root.right)) {
                    return false;
                }
            }
            return true;

         }


}
